#ifndef BISECTION_H
#define BISECTION_H

#include <cassert>
#include <stdint.h>
#include <vector>

namespace NumericalAnalysis
{
    // Input data for bisection method:
	// [a0, b0] interval
	// stopping bound
	// function
    struct BisectionInputData
    {
		BisectionInputData::BisectionInputData(const double leftLimit = 0.0, const double rightLimit = 0.0,
			const double stopBound = 0.0, double (*function) (const double x) = 0)
			: mLeftLimit(leftLimit)
			, mRightLimit(rightLimit)
			, mStopBound(stopBound)
			, mFunction(function)
		{
			assert(function && "BisectionInputData::BisectionInputData: NULL pointer");
		}	

    	double mLeftLimit;
    	double mRightLimit;
    	double mStopBound;
    	double (*mFunction) (const double x);
    };

    // Output data for bisection method:
	// list of approximations
	// last approximation
	// valued last approximation
    struct BisectionOutputData
    {
		BisectionOutputData::BisectionOutputData(const double lastApproximation = 0.0, const double valuedLastApproximation = 0.0)
			: mLastApproximation(lastApproximation)
			, mValuedLastApproximation(valuedLastApproximation)
		{

		}

    	std::vector<double> mApproximations;
    	double mLastApproximation;
    	double mValuedLastApproximation;
    };

    BisectionOutputData BisectionMethod(const BisectionInputData& inputData);
}

#endif // BISECTION_H
